home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d19
/
ckit15a.arc
/
CKITDEMO.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-08-13
|
12KB
|
331 lines
#include "ckit.h" /* Include CKIT Header file! */
#include "ckitdemo.h" /* Include file for demo */
#pragma check_stack (off)
/******************************************************************************
* Start of Main Program *
*****************************************************************************/
/* The main function MUST be prototyped as below using C's argc and
* argv array in your door program for use with CKIT.LIB.
*/
main(int argc, char **argv) { /* MUST HAVE MAIN PROTOTYPED AS SHOWN! */
/******************************************************************************
* USER adjustments *
* You will need to set these according to how you want CKIT to handle certain *
* options. See the CKIT.DOC for more information *
* Also see CKITDEMO.H for program name *
*******************************************************************************/
FORCEOFFHOOK = TRUE;
USERSFILE = TRUE;
LOGOFFMSG = FALSE;
if (argc > 0) {
open_door(argv[1], argv[2]);
display_info();
menu();
close_door();
exit(0);
}
}
/******************************************************************************
* End of Main Program *
******************************************************************************/
/******************************************************************************
* Main Menu *
******************************************************************************/
void menu(void) {
newline();
if(display_file("ckit.m")) { /* If error display_file() return NON_ZERO */
newline();
}
force_enter();
/* main command loop */
while(DUMP_USER != TRUE) {
/* prompt for input only if there is not a stacked command pending */
if ( strlen(cmdline) == 0) {
color(white);
newline();
s_puts("Main menu:\r\n");
color(red);
s_puts(" (I) Display system information\r\n");
color(green);
s_puts(" (C) Take a chance for more time online\r\n");
color(magenta);
s_puts(" (T) Display a test pattern\r\n");
color(cyan);
s_puts(" (A) Ansi graphics demo\r\n");
color(violet);
s_puts(" (D) Display information on CKIT\r\n");
color(green);
s_puts(" (F) Download CKIT.DOC using Zmodem \r\n");
color(red);
s_puts(" (Q) Return to PCBoard\r\n");
color(yellow);
newline();
do {
display_time();
color(green);
s_puts("Command? ");
get_cmdline(); /* read input into 'cmdline' */
newline();
} while( (DUMP_USER != TRUE) && ( strlen(cmdline) == 0 ));
}
if (DUMP_USER == TRUE) {
close_door();
exit(1);
}
if (get_nextpar()) { /* scan next parameter from cmdline into par */
/* process commands */
switch ( par[0] ) {
case 'A':
ansi_demo();
break;
case 'C':
take_chance();
break;
case 'I':
display_info();
break;
case 'T':
test_pattern();
break;
case 'D':
color(cyan);
display_file(doc_filename);
break;
case 'F':
color(cyan);
filexfer();
break;
case 'Q':
option = LOGOFF;
close_door();
exit(0);
break;
default:
newline();
color(magenta);
s_putv("(",par,") is not allowed! Try again:", NULL);
*cmdline = NULL;
newline();
break;
}
}
}
}
/******************************************************************************
* Display User information *
******************************************************************************/
void display_info(void) {
char s_out_str[34];
newline();
color(white);
s_putv(firstname,", Here is your User information:",NULL);
color(green);
newline();
s_putv(" Fullname = ",fullname,"\r\n",NULL);
s_putv(" Phone numbers = ",user.bphone," / ",user.phone,"\r\n",NULL);
s_putv(" City = ",user.city,"\r\n",NULL);
s_putv(" Baud Rate = ",baud_rate,"\r\n",NULL);
s_putv(" Last call date = ",user.last_date," at ",user.last_time,"\r\n",NULL);
s_putv(" Minutes left = ",itoa(min_left+time_credit,s_out_str,10),"\r\n",NULL);
s_putv(" Protocol is = ",user.protocol,"\r\n",NULL);
if(!PCB) {
s_putv(" Event runs at = ",event_time,"\r\n",NULL);
s_putv(" # of Downloads = ",dload_total, NULL);
s_putv(" Total K bytes = ",download_Kbytes,",",NULL);
s_putv(" Today's K bytes = ",daily_bytes,NULL);
newline();
s_putv(" Allowed K bytes = ",itoa(dload_limit,s_out_str,10),"\r\n",NULL);
s_putv(" # of Uploads = ",upload_total, NULL);
s_putv(" Total K bytes = ",upload_Kbytes,"\r\n",NULL);
}
s_puts(" Graphics = ");
if (graphics) {
s_puts("ON");
} else {
s_puts("OFF");
}
newline();
s_putv(" Page length = ", \
itoa(page_length,s_out_str,10),"\r\n", NULL);
color(yellow);
newline();
force_enter();
/*
* *cmdline = NULL; Use this if you don't want cmd stacking
*/
}
/******************************************************************************
* ANSI Demo *
******************************************************************************/
void ansi_demo(void) {
short x,y;
register short i;
if (graphics) { /* Check if user is in graphics mode */
clr_screen();
for (y=2; y < 24; y++) {
pos_cursor(y,1);
s_puts("│");
pos_cursor(y,79);
s_puts("│");
}
x = 2;
pos_cursor(1,x);
for(i = 0; i <= 1; i++) {
while(x < 79) {
s_puts("─");
x++;
}
x = 2;
pos_cursor(23,x);
}
pos_cursor(1,1);
s_puts("┌");
pos_cursor(1,79);
s_puts("┐");
pos_cursor(23,1);
s_puts("└");
pos_cursor(23,79);
s_puts("┘");
for(i = blue; i <= white; i++) {
color(i);
pos_cursor(i-8+3,11);
s_puts("ANSI Color display");
}
for(i = grey; i >= dkblue; i--) {
color(i);
pos_cursor(i+3, 50);
s_puts("ANSI Color display");
}
color(red);
pos_cursor(13,34);
s_puts("C - K I T");
color(yellow);
pos_cursor(16,14);
s_puts("This is only a SMALL sample of what C-Kit can do! ");
color(red);
pos_cursor(20,26);
} else {
newline();
s_puts("ANSI demo available only in GRAPHICS mode.\r\n");
}
force_enter();
/*
* *cmdline = NULL; Use this if you don't want cmd stacking
*/
clr_screen();
}
/*****************************************************************************
* Open door *
*****************************************************************************/
void test_pattern(void) {
int i;
newline();
for (i = 1; i < 21; i++) {
s_puts("(1234567890-abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789)\r\n");
}
/*
* *cmdline = NULL; Use this if you don't want cmd stacking
*/
}
/*****************************************************************************
* Filexfer doc file *
*****************************************************************************/
void filexfer(void) {
char xfer_file[46];
strcpy(xfer_file, zmodem_send);
strcat(xfer_file, doc_filename);
color(green);
s_putv("\nReady to send ", doc_filename, ". Press <ENTER> to begin.", NULL);
while(DUMP_USER != TRUE) {
if( check_CR() ) {
break;
}
}
if(dos_shell(xfer_file)) {
s_puts("\n\aTransfer aborted");
} else {
s_puts("\nTransfer complete");
}
/*
* *cmdline = NULL; Use this if you don't want cmd stacking
*/
}
/*****************************************************************************
* Take a chance on on-line time *
*****************************************************************************/
void take_chance(void) {
char thinking_of[5];
if(PCB) {
*cmdline = 0;
itoa(random(10),thinking_of,10);
if ( strlen(cmdline) == 0) {
color(cyan);
s_puts("I'm thinking of a number from 0 to 9. If you guess the\r\n");
s_puts("number, you will be given an extra 10 minutes online. If you\r\n");
s_puts("get it wrong, your time will be reduced by 2 minutes.\r\n");
newline();
color(yellow);
s_puts("What's your guess? ");
get_cmdline();
newline();
}
if (get_nextpar()) { /* scan next parameter from cmdline into par */
if (!strcmpi(thinking_of, par)) {
color(green);
s_puts("That's right! You get a 10 minute bonus!");
adjust_time_allowed(10);
} else {
color(blue);
s_putv("Wrong! You lose 2 minutes! I was thinking of ", thinking_of,".",NULL);
adjust_time_allowed(-2);
}
}
} else {
newline();
s_puts("Take chance only available with PCBOARD.SYS usage.\r\n");
}
}
/****************************************************************************
* IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF *
****************************************************************************/
#if COMPILER == MICROSOFT
int random(short Modulo) {
short seed;
check_time_left();
seed = system_time_HHMMSS[7] - 0x30;
return(RAND(seed));
}
#endif
/****************************************************************************
* ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF *
****************************************************************************/
/****************************************************************************/
/************************ E N D O F M O D U L E **************************/